qui(
    function (require, exports, module) {
        Specimen.Edit = function (options) {
            this.dao = Specimen.Dao;
            this.config = Specimen.Config;
            this.options = options || {};
        };

        Com.inherits(Specimen.Edit, Ancestor.Grid, function (options) {
        }).extend({
            init: function () {
                var self = this;
                self.bindEvent();
                if (Com.url.getParameter("qipu_id") != null) {
                    $("li[name=modifyText]").html("修改");
                    Specimen.Config.IS_MODIFY = true;
                    $("#modifyContainer").show();
                    self.initModifyHandler();
                } else {
                    $("li[name=modifyText]").html("添加");
                    Specimen.Config.IS_ADD = true;
                    $("#addContainer").show();
                    self.initAddHandler();
                }

            },
            initModifyHandler: function () {
                var self = this;
                var parent = $("#modifyContainer");
                var element = Specimen.Util.getAlbumDataByUrl()
                parent.find("span[name=span_album_id]").html(element.album_id);
                parent.find("input[name=input_news_name]").val(element.news_name);
                parent.find("span[name=span_startTime]").html(element.start_time);
                parent.find("span[name=span_endTime]").html(element.end_time);
                parent.find("span[name=span_qipu_id]").html(element.qipu_id);
                parent.find("span[name=span_album_name]").html(element.album_name);
                parent.find("span[name=span_channel_name]").html(element.channel);

            },
            initAddHandler: function () {
                var self = this;
                $('div[name=multiAddDiv]').addndel({
                    rowClass: 'control-group',
                    insertOrder:"after",
                    addDecorator: function ($newRow, $clickedRow) {
                        if ($(".my-border").length == 10) {
                            SystemDialog.queryAlert("最多同时编辑10个！");
                            return false;
                        }
                        $newRow.find("input[name=input_startTime]").datepicker({dateFormat: "yymmdd"});
                        $newRow.find("input[name=input_endTime]").datepicker({dateFormat: "yymmdd"});
                        return true;
                    }
                })

                $("input[name=input_startTime]").datepicker({dateFormat: "yymmdd"});
                $("input[name=input_endTime]").datepicker({dateFormat: "yymmdd"});
            },
            bindEvent: function () {
                $("button[name=btn_submit]").bind("click", function (e) {
                    if (Specimen.Config.IS_MODIFY) {
                        Specimen.Util.submitModifySpecimen();
                    } else if (Specimen.Config.IS_ADD) {
                        Specimen.Util.submitNewSpecimen();
                    }
                })
                $("button[name=btn_goback]").bind("click", function (e) {
                    Specimen.Util.goBackToList("取消");
                })
            }

        })
    }
);